package com.haihong.consumer.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * 测试service
 *
 * @author admin
 * @version 1.0  2019/8/20 15:19
 */
@Service
public class TestCloudService {

    @Autowired
    private RemoteInterface remoteInterface;

    /*@Autowired
    RestTemplate restTemplate;

    public Object getOtherInfo(String name) {
        long start = System.currentTimeMillis();
        ResponseEntity<Object> info = restTemplate.getForEntity("http://provider/user/getInfo?userName=" + name, Object.class);
        long end = System.currentTimeMillis();
        System.out.println("耗时：" + (end - start));
        return info;
    }*/

    public Object getOtherInfo(String userName) {
        long start = System.currentTimeMillis();
        Object userInfo = remoteInterface.getUserInfo(userName);
        long end = System.currentTimeMillis();
        System.out.println("耗时：" + (end - start));
        return userInfo;
    }
}
